/*
 * Formation.java
 *
 * Created on 18 de noviembre de 2007, 03:56 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package nx.formations;


import nx.utils.Vector2D;
/**
 *
 * @author alejo
 */
public abstract class Formation {
    
    private int numRobots;
    private double thetaVar;
    private double thetaInic;
    private String name;
    protected double width;
    protected double scaleFactor;
    protected double minWidth;
    
    /** Creates a new instance of Formation */
    public Formation(int numRobots) {
        thetaInic = 0;
        setNumRobots(numRobots);
    }
    
    public void setNumRobots(int numRobots){
        
        this.numRobots = numRobots;
        this.thetaVar = (float) Math.PI * 2 / numRobots;
        
        if(numRobots % 2 == 0)
            this.setThetaInic((float)(Math.PI / numRobots)); 
        else
            this.setThetaInic(0);
        
    
    }
    
    public double getThetaVar(){
        return this.thetaVar;
    }
    
    public double getThetaInic(){
        return this.thetaInic;
    }
    
    public void setThetaInic(double thetaInic){
        this.thetaInic = thetaInic;
    }
    
    public int getNumRobots(){
        return this.numRobots;
    }
    
    public String getName() {
        return name;
    }
    
    public void setName(String name){
        this.name = name;
    
    }
    
    public void setWidth(double width){
        this.width = width;
    }
    
    public double getWidth(){
        return this.width;
    }
       
    public double getScaleFactor(){
        calculateScaleFactor();
        return this.scaleFactor;
    }
    
    public double getRobotLocationDir(int robotId){
        return this.getThetaInic() +(this.getThetaVar()*robotId); 
    
    }
    
    public abstract Vector2D getRobotPosition(int robotId);
    public abstract void calculateScaleFactor();
    
    
    
}
